package org.mc.sbd.mock.infrastructure;

import lombok.extern.slf4j.Slf4j;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.Collections;

@RestControllerAdvice
@Slf4j
public class DefaultExceptionAdvice {
    @ExceptionHandler(value = BizException.class)
    public ResponseEntity<Object> handleException(BizException exception) {
        return ResponseEntity.status(HttpStatus.OK).body(Collections.singletonList(exception.getMessage()));
    }
}
